package net.bplaced.streetfighter.lib.async.task;

import net.bplaced.streetfighter.lib.model.Comment;
import net.bplaced.streetfighter.lib.service.CommentLoaderServiceImpl;
import net.bplaced.streetfighter.lib.utils.CallBack;
import net.bplaced.streetfighter.lib.utils.ServiceReturnPackage;
import android.content.Context;

/**
 * @author Sebastian Hoffmann <bo.hoffi@googlemail.com>
 */
public class CommentLoaderTask
        extends AbstractLoaderTask<Integer, ServiceReturnPackage<Comment[]>> {

    public CommentLoaderTask(Context context, String progressMessage,
            CallBack<ServiceReturnPackage<Comment[]>> onFinished) {

        super(context, progressMessage, onFinished);
    }

    @Override
    ServiceReturnPackage<Comment[]> performInBackground(Integer... startIndexes) {

        if (startIndexes.length != 1) {
            return null;
        }

        return new CommentLoaderServiceImpl().loadCommentsViaPOST(startIndexes[0]);
    }
}